<template>
  <el-drawer
    title="选择客户群"
    :visible.sync="$attrs.visable"
    :size="width"
    :before-close="handleClose"
    append-to-body
    class="groupdia"
  >
    <div class="flex h_box">
      <div class="box1 box2 h_full">
        <div class="boxheader flexbetween">
          <span>筛选</span>
          <el-button type="primary" size="small" plain class="p-3"
            >清空条件</el-button
          >
        </div>
        <div class="boxbody">
          <client-form />
          <div class="flexbetween bg_f7f7f7 p-8 e_exclude">
            <div class="fw-6 flexcenter">
              设置排除条件
              <el-switch
                v-model="exclude"
                active-color="#3070ff"
                inactive-color="#c7c5c5"
                active-value="1"
                inactive-value="0"
                class="ml-6"
              >
              </el-switch>
            </div>
            <div class="c_warning2">开启后将排除满足以下条件客户群</div>
          </div>
          <client-form v-if="exclude == 1" />
        </div>
      </div>
      <div v-if="!isTable" class="box1 box3 h_full">
        <div class="boxheader flexbetween">
          <div>
            <el-checkbox v-model="checkedAll"></el-checkbox
            ><span class="c_text2 ml-12">全选本页</span>
          </div>
          <el-button size="mini" type="primary" plain>全选所有</el-button>
        </div>
        <div class="boxbody p-0">
          <div
            class="groupitem flex aligncenter"
            v-for="(item, index) in grouplist"
            :key="index"
          >
            <div class="flex groupleft">
              <div class="checkbox flexcenter">
                <el-checkbox v-model="item.checked"></el-checkbox>
              </div>
              <div class="accoutitem commhover flex mb-3">
                <img
                  src="https://wework.qpic.cn/wwpic/576270_jL0ikDqEQ1SA2FC_1697685555/0"
                  alt=""
                  class="avatar mr-12"
                />
                <div class="itemcontent">
                  <div class="c_text2 f-14 textover line_h_24">测试群</div>
                  <div class="c_666 f-12 textover line_h_20">群成员3</div>
                </div>
              </div>
            </div>
            <!-- <div class="labelbox f-12">群主</div> -->
          </div>
        </div>
      </div>
      <div v-if="isTable" class="box1 box3 h_full">
        <el-table
          v-loading="loading"
          :data="grouplist"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="80" fixed align="center" />
          <el-table-column
            label="客户群（19）"
            prop="userName"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <div class="flex kh_box aligncenter">
                <img
                  src="//qyb-1253970052.cos.ap-shanghai.myqcloud.com/public/wechatdata/avatar/5424982/e9564f7860994fe258a93da3a18c1a2c.png"
                  alt=""
                  class="useravatar"
                />
                <div class="khnamebox flex pl-12">
                  <div class="title c_222333">{{ scope.row.title }} </div>
                  <div>群成员：2</div>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            label=""
            prop="nickName"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <el-tag type="info" v-if="scope.row.tag">群主</el-tag>
              <span v-else>--</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="dialog-footer flexbetween">
      <div>
        <span>已选择：<span class="c_warning2"> {{multipleSelection.length}} </span> 客户群</span>
        <span v-if="multipleSelection.length" class="c_primary commhover ml-12">清除已选</span>
      </div>
      <div>
        <el-button size="small" @click="handleClose">取 消</el-button>
        <el-button size="small" type="primary" @click="handleSubmit">确 定</el-button>
      </div>
    </div>
  </el-drawer>
</template>
<script>
import ClientForm from "./components/ClientForm.vue";
export default {
  data() {
    return {
      queryParams: {
        keyword: "",
      },
      exclude: 0,
      // form: {
      //   grouptype: 1,
      //   name: "",
      //   labels: [],
      //   labeltype: 1,
      //   grouplabel: "",
      //   min: "",
      //   max: "",
      // },
      // visible: false,
      // numberstr: "",
      grouplist: [{ id: 1, name: "测试群", checked: false }],
      checkGroupList: [{ id: 1, name: "测试群", checked: false }],
      checkedAll: false, //全选
      multipleSelection: [],
    };
  },
  props: {
    width: {
      type: String,
      default: "860px",
    },
    height: {
      type: String,
      default: "700px",
    },
    isTable: {
      //列表是否是表格
      type: Boolean,
      default: false,
    },
  },
  components: {
    ClientForm,
  },
  methods: {
    handleClose() {
      this.$emit("close", 1); //关闭弹窗;
      this.$emit("update:visable", false);
    },

    // handleAddLable() {
    //   if (this.form.name) {
    //     if (this.form.labels.includes(this.form.name)) {
    //       this.$message.warning("标签重复");
    //       return;
    //     }
    //     this.form.labels.push(this.form.name);
    //     this.form.name = "";
    //   }
    // },

    removeLable(index) {
      this.form.labels.splice(index, 1);
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.multipleSelection = selection.map((item) => item.id);
      //   this.single = selection.length != 1;
      this.multiple = !selection.length;
    },

    // submitNum() {
    //   this.numberstr = this.form.min + " ~ " + this.form.max;
    //   console.log("this.numberstr:", this.numberstr);
    //   this.visible = false;
    // },

    handleSubmit() {},
  },
};
</script>

<style lang="scss" scoped>
.h_box {
  height: calc(100% - 56px);
  // height: 700px;
}
.box1 {
  width: 250px;
  border-right: 1px solid #e9e9e9;
}
.box2 {
  width: 400px;
}
.boxheader {
  padding: 0 12px;
  height: 42px;
  background: #fafafa;
  border-bottom: 1px solid #e9e9e9;
  position: sticky;
  top: 0;
  z-index: 11;
}
.groupdia {
  ::v-deep .el-dialog__body {
    padding: 0;
  }
}
.input-with-select {
  width: 225px;

  ::v-deep .el-input-group__append {
    padding: 0 14px;
    background-color: #fff;
  }
}
.boxbody {
  height: calc(100% - 52px);
  overflow-y: auto;
  padding: 10px 0;
}
.accoutitem {
  padding: 6px 12px;
  &.active {
    background-color: #ebf2ff;
  }
  &:hover {
    background-color: #f0f0f0;
  }

  .avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
  }
  .itemcontent {
    width: calc(100% - 52px);
  }
}
.filterform {
  padding: 0 16px;
  ::v-deep .el-form-item__label {
    line-height: 26px;
    padding-bottom: 0;
  }
  ::v-deep .el-input-group__append {
    padding: 0 14px;
  }
}
.labelitem {
  display: inline-block;
  border-radius: 4px;
  border: 1px solid #e9e9e9;
  background-color: #fafafa;
  padding: 2px 7px;
  line-height: 22px;
}
.box3 {
  width: 460px;
  flex: 1 1;
}
.groupitem {
  width: 100%;
  padding: 2px 0;
  border-bottom: 1px solid #f5f5f5 !important;
  &.active {
    background-color: #ebf2ff;
  }
  &:hover {
    background-color: #f0f0f0;
  }

  .groupleft {
    width: calc(100% - 50px);
  }
  .checkbox {
    width: 40px;
  }
  .labelbox {
    background: #f1f1f4;
    border-radius: 2px;
    border: 1px solid #c1c1f1;
    color: #4b5a95;
    line-height: 20px;
    padding: 2px 8px;
  }
  .g_name {
    width: 90%;
  }
}
.box4 {
  width: 240px;
}
.e_exclude {
  margin: 20px 16px;
}
.dialog-footer{
  padding: 10px 16px;
  border-top: 1px solid #e9e9e9;
}
</style>